package com.zlt.appparking.controller;


import com.zlt.appparking.dto.FeedBackDTO;
import com.zlt.appparking.service.FeedBackService;
import com.zlt.appparking.utils.RegularUtil;
import com.zlt.appparking.vo.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@Slf4j
@RestController
@RequestMapping("feedback")
public class FeedBackController {

    @Autowired
    private FeedBackService feedBackService;

    /**
     * 添加反馈
     *
     * @param feedBackDTO
     * @return
     */
    @PutMapping("insert_feedback")
    public Result insertFeedback(@RequestBody FeedBackDTO feedBackDTO) {

        log.debug("反馈信息{}", feedBackDTO);

        try {
            boolean success = feedBackService.insertFeedback(feedBackDTO);
            return success ? Result.ok("添加成功") : Result.error("添加失败");
        } catch (RuntimeException e) {
            return Result.error(e.getMessage());
        }
    }


}
